Class NewsServiceTest

java.lang.Object
com.fsf.news.service.NewsServiceTest

@ExtendWith(org.mockito.junit.jupiter.MockitoExtension.class) class NewsServiceTest extends Object
Unit tests for the NewsService class.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) com.fsf.news.client.NewsApiClient
     
    (package private) com.fsf.news.processor.NewsFleschMetricsProcessor
     
    (package private) com.fsf.news.model.form.NewsForm
     
    (package private) play.twirl.api.Html
     
    (package private) com.fasterxml.jackson.databind.JsonNode
     
    (package private) com.fsf.news.renderer.NewsRenderer
     
    (package private) com.fsf.news.repository.NewsRepository
     
    (package private) com.fsf.news.processor.NewsResponseProcessor
     
    (package private) com.fsf.news.processor.NewsSentimentProcessor
     
    (package private) com.fsf.news.service.NewsService
     
    (package private) com.fsf.news.processor.NewsWordStatsProcessor
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
    Tests that the addSearchResult method adds a search result and returns the expected result.
    (package private) void
    Tests that the addSearchResult method throws an exception when no session ID is provided.
    (package private) void
    Tests that the getSearchResults method returns the expected results.
    (package private) void
    Tests that the getSearchResults method throws an exception when no session ID is provided.
    (package private) void
    Tests that the getSearchResultWordStats method returns the expected word statistics for a given search result.
    (package private) void
    Tests that the getSearchResultWordStats method throws an exception when no search result is found.
    (package private) void
    Tests that the getSearchResultWordStats method throws an exception when no session ID is provided.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • service

      @InjectMocks com.fsf.news.service.NewsService service
    • apiClient

      @Mock com.fsf.news.client.NewsApiClient apiClient
    • responseProcessor

      @Mock com.fsf.news.processor.NewsResponseProcessor responseProcessor
    • wordStatsProcessor

      @Mock com.fsf.news.processor.NewsWordStatsProcessor wordStatsProcessor
    • fleschMetricsProcessor

      @Mock com.fsf.news.processor.NewsFleschMetricsProcessor fleschMetricsProcessor
    • sentimentProcessor

      @Mock com.fsf.news.processor.NewsSentimentProcessor sentimentProcessor
    • renderer

      @Mock com.fsf.news.renderer.NewsRenderer renderer
    • repository

      @Mock com.fsf.news.repository.NewsRepository repository
    • form

      @Mock com.fsf.news.model.form.NewsForm form
    • jsonNode

      @Mock com.fasterxml.jackson.databind.JsonNode jsonNode
    • html

      @Mock play.twirl.api.Html html
  • Constructor Details

    • NewsServiceTest

      NewsServiceTest()
  • Method Details

    • testGetSearchResults

      @Test void testGetSearchResults()
      Tests that the getSearchResults method returns the expected results.
    • testGetSearchResultsException

      @Test void testGetSearchResultsException()
      Tests that the getSearchResults method throws an exception when no session ID is provided.
    • testAddSearchResult

      @Test void testAddSearchResult()
      Tests that the addSearchResult method adds a search result and returns the expected result.
    • testAddSearchResultException

      @Test void testAddSearchResultException()
      Tests that the addSearchResult method throws an exception when no session ID is provided.
    • testGetSearchResultWordStats

      @Test void testGetSearchResultWordStats()
      Tests that the getSearchResultWordStats method returns the expected word statistics for a given search result.
    • testGetSearchResultWordStatsException

      @Test void testGetSearchResultWordStatsException()
      Tests that the getSearchResultWordStats method throws an exception when no session ID is provided.
    • testGetSearchResultWordStatsEmpty

      @Test void testGetSearchResultWordStatsEmpty()
      Tests that the getSearchResultWordStats method throws an exception when no search result is found.